/*
 * @Author: LZQ lzq518@163.com
 * @Date: 2024-09-06 02:11:02
 * @LastEditors: LZQ lzq518@163.com
 * @LastEditTime: 2024-12-08 19:45:43
 * @FilePath: \RuoYi-Vue3\src\store\modules\app.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Cookies from 'js-cookie'
const useAppStore = defineStore('app', {
  state: () => ({
    sidebar: {
      opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
      withoutAnimation: false,
      hide: false,
    },
    device: 'desktop',
    size: Cookies.get('size') || 'default',
    showMode: 'goods',
    collectionType: [
      {
        name: '微信',
        value: 'WX',
        choose: true,
      },
      {
        name: '支付宝',
        value: 'ZFB',
        choose: false,
      },
      {
        name: '现金',
        value: 'XJ',
        choose: false,
      },
      {
        name: '会员钱包',
        value: 'QB',
        choose: false,
      },
      {
        name: '银联',
        value: 'YL',
        choose: false,
      },
    ],
  }),
  actions: {
    toggleMode(mode) {
      this.showMode = mode
    },
    toggleSideBar(withoutAnimation) {
      if (this.sidebar.hide) {
        return false
      }
      this.sidebar.opened = !this.sidebar.opened
      this.sidebar.withoutAnimation = withoutAnimation
      if (this.sidebar.opened) {
        Cookies.set('sidebarStatus', 1)
      } else {
        Cookies.set('sidebarStatus', 0)
      }
    },
    closeSideBar({ withoutAnimation }) {
      Cookies.set('sidebarStatus', 0)
      this.sidebar.opened = false
      this.sidebar.withoutAnimation = withoutAnimation
    },
    toggleDevice(device) {
      this.device = device
    },
    setSize(size) {
      this.size = size
      Cookies.set('size', size)
    },
    toggleSideBarHide(status) {
      this.sidebar.hide = status
    },
  },
})

export default useAppStore
